package com.chris.libs.base.x.mvpp.recycler;

import android.content.Context;

import com.alibaba.android.vlayout.LayoutHelper;

import java.util.List;

/**
 * Create by Chris Chan
 * Create on 2023/4/1 8:26
 * Use for:
 * Explain:
 */
public final class DefaultVLayoutAdapterBuilder<D, VH extends BaseVLayoutViewHolder<D>> {
    protected String tag = "TAG";
    protected Context context;
    protected BaseVLayoutAdapter.OnItemClickListener onItemClickListener;
    private int layoutId;
    private Class<VH> viewHolderClass;
    private LayoutHelper layoutHelper;
    private List<D> dataList;

    private DefaultVLayoutAdapterBuilder() {
    }

    public static <D, VH extends BaseVLayoutViewHolder<D>> DefaultVLayoutAdapterBuilder<D, VH> newBuilder() {
        return new DefaultVLayoutAdapterBuilder<>();
    }

    public DefaultVLayoutAdapterBuilder<D, VH> setLayoutId(int layoutId) {
        this.layoutId = layoutId;
        return this;
    }

    public DefaultVLayoutAdapterBuilder<D, VH> setViewHolderClass(Class<VH> viewHolderClass) {
        this.viewHolderClass = viewHolderClass;
        return this;
    }

    public DefaultVLayoutAdapterBuilder<D, VH> setLayoutHelper(LayoutHelper layoutHelper) {
        this.layoutHelper = layoutHelper;
        return this;
    }

    public DefaultVLayoutAdapterBuilder<D, VH> setTag(String tag) {
        this.tag = tag;
        return this;
    }

    public DefaultVLayoutAdapterBuilder<D, VH> setContext(Context context) {
        this.context = context;
        return this;
    }

    public DefaultVLayoutAdapterBuilder<D, VH> setOnItemClickListener(BaseVLayoutAdapter.OnItemClickListener onItemClickListener) {
        this.onItemClickListener = onItemClickListener;
        return this;
    }

    public DefaultVLayoutAdapterBuilder<D, VH> setDataList(List<D> dataList) {
        this.dataList = dataList;
        return this;
    }

    public DefaultVLayoutAdapter<D, VH> build() {
        return new DefaultVLayoutAdapter<>(tag, context, layoutId, viewHolderClass, layoutHelper, dataList, onItemClickListener);
    }
}
